package com.wkk.nursinghome.dao;

import com.wkk.nursinghome.domain.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IEmployeeDao {
    //根据编号查询员工信息
    @Select("select * from employee where id=#{id}")
    public Employee selectEmployeeById(Integer id);

    //查询所有员工信息
    @Select("select * from employee order by id asc")
    public List<Employee> selectAll();

    //添加员工信息
    @Insert("insert into employee (name, sex,age,emnumber,type,entrytime,operator,optime,position,jobtitle,status,introduction,remarks) " +
            "values (#{name}, #{sex},#{age}, #{emnumber},#{type}, #{entrytime},#{operator}, #{optime},#{position}, #{jobtitle},#{status}, #{introduction},#{remarks})")
    @SelectKey(statement = "select LAST_INSERT_ID()",keyProperty = "id",before = false,resultType = Integer.class)
    public int insertEmployee(Employee employee);

    //删除员工信息
    @Delete("delete from employee where id=#{id}")
    public int deleteEmployeeById(Integer id);

    //修改员工信息
    @UpdateProvider(type = EmployeeSQLProvider.class,method = "updateEmployee")
    public int updateEmployee(Employee employee);

    //根据条件查询员工信息
    @SelectProvider(type = EmployeeSQLProvider.class,method = "selectEmployeeByCondition")
    public List<Employee> getEmployeeByCondition(Employee employee);

    //登录
    @Select("Select id,name from employee where id=#{id} and name=#{name}")
    public int login(@Param("id")Integer id,@Param("name")String name);
}
